﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Utils.Attributes;
using System.Web.Mvc;

namespace Prerequisites.Models
{
    public class FormModel
    {
        [Required(ErrorMessage = "Introduceti un Id")]
        [Display(Name = "Id:")]
        public int? Id { get; set; }

        [Required(ErrorMessage = "Introduceti o data")]
        [Display(Name = "Data:")]
        [DateFormat(GreaterThan = "2012-05-10", ErrorMessage = "Format gresit")]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "dd-MM-yyyy")]
        public DateTime? AddDate { get; set; }

        [Required(ErrorMessage = "Introduceti un nume")]
        [MustBe(Condition.NotEqualTo, "caca", ErrorMessage = "Name nu trebuie sa fie 'caca'")]
        [Display(Name = "Nume:")]
        public string Name { get; set; }

        [Required(ErrorMessage = "Introduceti o suma")]
        [Display(Name = "Suma:")]
        public decimal? Amount { get; set; }

        [Display(Name = "Optiune:")]
        public int Option { get; set; }

        public List<SelectListItem> Options { get; set; }

        [Display(Name = "HtmlText:")]
        public string HtmlText { get; set; }

        [Display(Name = "Slider no:")]
        public int SliderNo { get; set; }

        public FormModel()
        {
            Options = new List<SelectListItem>();

            Options.Add(new SelectListItem
            {
                Text = "a 1",
                Value = "1"
            });

            Options.Add(new SelectListItem
            {
                Text = "a 2",
                Value = "2"
            });

            Options.Add(new SelectListItem
            {
                Text = "b 1",
                Value = "1"
            });

            Options.Add(new SelectListItem
            {
                Text = "b 2",
                Value = "2"
            });
        }

    }
}